From 2e21994a8294399992f90618e0ea130408490d3f Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 18 Mar 2008 16:15:24 +0000 Subject: [PATCH] x86: stub domains and page ownership for mapping in dom0 In the case of an ioemu stubdomain with SDL or vnc server running in dom0, we want to have the stubdomain expose the HVM guest's video RAM through PVFB. However, to map the pages from dom0, xenfb uses xc_map_foreign_pages with the stubdomain ID as domid (since that is what is advertised in the PVFB protocol, and needed for other parts of the protocol), and thus get_page_from_l1e() complains because the stubdomain is not the owner of the pages. In such case, this patch checks that the stubdomain has privileges on the actual owner of the pages, and then accept the mapping. Signed-off-by: Samuel Thibault --- xen/arch/x86/mm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index e84b185598..5f8e2a8b78 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -645,6 +645,7 @@ get_page_from_l1e( struct page_info *page = mfn_to_page(mfn); uint32_t l1f = l1e_get_flags(l1e); struct vcpu *curr = current; + struct domain *owner = page_get_owner(page); int okay; if ( !(l1f & _PAGE_PRESENT) ) @@ -673,6 +674,16 @@ get_page_from_l1e( return 1; } + /* + * Let privileged domains transfer the right to map their target + * domain's pages. This is used to allow stub-domain pvfb export to dom0, + * until pvfb supports granted mappings. At that time this minor hack + * can go away. + */ + if ( unlikely(d != owner) && (owner != NULL) && + (d != curr->domain) && IS_PRIV_FOR(d, owner) ) + d = owner; + /* Foreign mappings into guests in shadow external mode don't * contribute to writeable mapping refcounts. (This allows the * qemu-dm helper process in dom0 to map the domain's memory without -- 2.30.2